# -*- coding: utf-8 -*- 
# @Time : 2021/4/5 18:58 
# @Author : Dong 
# @File : ss.py
import re
import time
from multiprocessing import Pool
import requests
from urllib.parse import urlencode
from pyquery import PyQuery as pq
#
# with open('sss.html','r',encoding='utf-8')as book:
#     fash = book.read()


#
# pattern2 = re.compile('</span><a href="(/streetstyle/.*?)">')
# item2 = re.findall(pattern2,fash)
# print(item2)




data = {"requests":[{
    "indexName":"entries_date",
    "params":"query",
    'hitsPerPage': '40',
    'page': '0',
    'highlightPreTag': '__ais-highlight__',
    'highlightPostTag': '__/ais-highlight__',
    'filters': 'blog.id:2 AND NOT objectID:173095 AND NOT objectID:173031 AND NOT objectID:173029 AND NOT objectID:173025 AND NOT objectID:173024 AND NOT objectID:173023',
    'facets': ["blog.id","tags","blog.id"],
    'tagFilters':""}]}

#
headers = {
    'accept': 'application/json',
    'Accept-Encoding': 'gzip, deflate, br',
    'Accept-Language': 'en,zh-CN;q=0.9,zh;q=0.8',
    'Connection': 'keep-alive',
    'Content-Length': '435',
    'content-type': 'application/x-www-form-urlencoded',
    'Host': 'zgispfzeqk-3.algolianet.com',
    'Origin': 'https://www.fashionsnap.com',
    'Referer': 'https://www.fashionsnap.com/',
    'sec-ch-ua': '"Google Chrome";v="89", "Chromium";v="89", ";Not A Brand";v="99"',
    'sec-ch-ua-mobile': '?0',
    'Sec-Fetch-Dest': 'empty',
    'Sec-Fetch-Mode': 'cors',
    'Sec-Fetch-Site': 'cross-site',
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36',
    "cookie": "_gcl_au:1.1.991844184.1617971826; _ga=GA1.2.534436873.1617971826; _gid=GA1.2.1835158820.1617971826; __gads=ID=f79da018af5c29bd:T=1617971826:S=ALNI_MZRvId5-kLHOcItBVfUBdmCql325g; _fbp=fb.1.1617971834164.1832946184; __qca=P0-1670811500-1617971838563"
}
#
params = {
    'x-algolia-agent': 'Algolia for vanilla JavaScript 3.32.1;instantsearch.js 3.1.0;JS Helper 2.26.1',
    'x-algolia-application-id': 'ZGISPFZEQK',
    'x-algolia-api-key': '26419353d7349d3548348cb981892a31',
}
#
data2 = {
    "requests":[
        {
    "indexName":"entries_date",
    "params":"query:",
    "hitsPerPage": "40",
    "page": "1",
    "highlightPreTag": "__ais-highlight__",
    "highlightPostTag": "__%2Fais-highlight__",
    "filters": "blog.id%3A2%20AND%20NOT%20objectID%3A173095%20AND%20NOT%20objectID%3A173031%20AND%20NOT%20objectID%3A173029%20AND%20NOT%20objectID%3A173025%20AND%20NOT%20objectID%3A173024%20AND%20NOT%20objectID%3A173023",
    "facets": "%5B%22blog.id%22%2C%22tags%22%2C%22blog.id%22%5D",
    "tagFilters": ""
        }
    ]
}
# print('https://zgispfzeqk-3.algolianet.com/1/indexes/*/queries' + urlencode(params))
# # rep=requests.post(url='https://zgispfzeqk-3.algolianet.com/1/indexes/*/queries' + urlencode(params),headers=headers)
# response = requests.post('https://zgispfzeqk-3.algolianet.com/1/indexes/*/queries' + urlencode(params), headers=headers,data=data2)
#
# # print(rep)
# print(response.text)





# import re
#
#
# def headers_to_dict(headers_str, out_put=True):
#     items = headers_str.strip().split('\n')
#     headers_dict = {}
#     for t in items:
#         key, value = re.findall(r'^(\S+):\s*([\s\S]+)$', t)[0]
#         headers_dict[key] = value
#         if out_put:
#             print(f"'{key}': '{value}',")
#     return headers_dict
#
#
# headers_to_dict('''"requests":[{"indexName":"entries_date","params":"query:
# hitsPerPage: 40
# page: 1
# highlightPreTag: __ais-highlight__
# highlightPostTag: __%2Fais-highlight__
# filters: blog.id%3A2%20AND%20NOT%20objectID%3A173095%20AND%20NOT%20objectID%3A173031%20AND%20NOT%20objectID%3A173029%20AND%20NOT%20objectID%3A173025%20AND%20NOT%20objectID%3A173024%20AND%20NOT%20objectID%3A173023
# facets: %5B%22blog.id%22%2C%22tags%22%2C%22blog.id%22%5D
# tagFilters: "}]''')





import requests

# headers = {
#     'Connection': 'keep-alive',
#     'sec-ch-ua': '"Google Chrome";v="89", "Chromium";v="89", ";Not A Brand";v="99"',
#     'accept': 'application/json',
#     'sec-ch-ua-mobile': '?0',
#     'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36',
#     'content-type': 'application/x-www-form-urlencoded',
#     'Origin': 'https://www.fashionsnap.com',
#     'Sec-Fetch-Site': 'cross-site',
#     'Sec-Fetch-Mode': 'cors',
#     'Sec-Fetch-Dest': 'empty',
#     'Referer': 'https://www.fashionsnap.com/',
#     'Accept-Language': 'en,zh-CN;q=0.9,zh;q=0.8',
# }


# data3 = {
#   '"requests":[{"indexName":"entries_date","params":"query': '',
#   'hitsPerPage': '40',
#   'page': '1',
#   'highlightPreTag': '__ais-highlight__',
#   'highlightPostTag': '__/ais-highlight__',
#   'filters': 'blog.id:2 AND NOT objectID:173095 AND NOT objectID:173031 AND NOT objectID:173029 AND NOT objectID:173025 AND NOT objectID:173024 AND NOT objectID:173023',
#   'facets': '["blog.id","tags","blog.id"]',
#   'tagFilters': '"}]'
# }
# a = {
# "hitsPerPage": 40,
# "page": 1,
# "highlightPreTag": "__ais-highlight__",
# "highlightPostTag": "__/ais-highlight__",
# "filters: blog.id":"2 AND NOT objectID:173110 AND NOT objectID:173095 AND NOT objectID:173031 AND NOT objectID:173029 AND NOT objectID:173025 AND NOT objectID:173024"
# "tagFilters”: ",
# }
# response2 = requests.post('https://zgispfzeqk-3.algolianet.com/1/indexes/*/queries?' + urlencode(params), headers=headers,data=data2)
# print('https://zgispfzeqk-3.algolianet.com/1/indexes/*/queries?' + urlencode(params))
# print(response2.text)





# 新的
url = 'https://droptokyo.com/freshsnaps/?page_num=4'

a = {'freshsnaps': [{'type': 'freshsnaps', 'url': '/freshsnaps/ID/?id=288782', 'image': 'https://static.droptokyo.com/wp-content/uploads/2021/03/30015804/e214.jpg', 'name': 'UNKNOWN &#8211; NEW YORK'}, {'type': 'freshsnaps', 'url': '/freshsnaps/ID/?id=289096', 'image': 'https://static.droptokyo.com/wp-content/uploads/2021/04/02043921/u2.jpg', 'name': 'NANA TAKEHAMA &#8211; TOKYO'}, {'type': 'freshsnaps', 'url': '/freshsnaps/ID/?id=289082', 'image': 'https://static.droptokyo.com/wp-content/uploads/2021/04/02042058/i2.jpg', 'name': 'TAO &#8211; TOKYO'}, {'type': 'freshsnaps', 'url': '/freshsnaps/ID/?id=289070', 'image': 'https://static.droptokyo.com/wp-content/uploads/2021/04/02041309/y2.jpg', 'name': 'RYUNOSUKE &#8211; TOKYO'}, {'type': 'freshsnaps', 'url': '/freshsnaps/ID/?id=288916', 'image': 'https://static.droptokyo.com/wp-content/uploads/2021/03/30064329/x21.jpg', 'name': 'SHUFEN &#8211; CHINA'}, {'type': 'freshsnaps', 'url': '/freshsnaps/ID/?id=288867', 'image': 'https://static.droptokyo.com/wp-content/uploads/2021/03/30034953/w217.jpg', 'name': 'FELIZE &#8211; PARIS'}, {'type': 'freshsnaps', 'url': '/freshsnaps/ID/?id=289114', 'image': 'https://static.droptokyo.com/wp-content/uploads/2021/04/03010033/q2.jpg', 'name': 'SHO SUGIMOTO &#8211; KANSAI'}, {'type': 'freshsnaps', 'url': '/freshsnaps/ID/?id=289126', 'image': 'https://static.droptokyo.com/wp-content/uploads/2021/04/03010454/w2.jpg', 'name': 'KANO &#8211; KANSAI'}, {'type': 'freshsnaps', 'url': '/freshsnaps/ID/?id=288777', 'image': 'https://static.droptokyo.com/wp-content/uploads/2021/03/30015436/w139.jpg', 'name': 'UNKNOWN &#8211; NEW YORK'}, {'type': 'freshsnaps', 'url': '/freshsnaps/ID/?id=289731', 'image': 'https://static.droptokyo.com/wp-content/uploads/2021/04/08031454/q27.jpg', 'name': 'JO GUNHEE &#8211; KOREA'}, {'type': 'freshsnaps', 'url': '/freshsnaps/ID/?id=289010', 'image': 'https://static.droptokyo.com/wp-content/uploads/2021/04/01101240/z2.jpg', 'name': 'IORI WADA &#8211; TOKYO'}, {'type': 'freshsnaps', 'url': '/freshsnaps/ID/?id=288713', 'image': 'https://static.droptokyo.com/wp-content/uploads/2021/03/26025451/g25.jpg', 'name': 'KOTY &#8211; TOKYO'}, {'type': 'freshsnaps', 'url': '/freshsnaps/ID/?id=289034', 'image': 'https://static.droptokyo.com/wp-content/uploads/2021/04/01104318/s2.jpg', 'name': 'IORI YAMAKI AND RIKU &#8211; TOKYO'}, {'type': 'freshsnaps', 'url': '/freshsnaps/ID/?id=289022', 'image': 'https://static.droptokyo.com/wp-content/uploads/2021/04/01103430/a2.jpg', 'name': 'MIYUU KOBAYASHI &#8211; TOKYO'}, {'type': 'freshsnaps', 'url': '/freshsnaps/ID/?id=288861', 'image': 'https://static.droptokyo.com/wp-content/uploads/2021/03/30034738/q222.jpg', 'name': 'EMMA &#8211; PARIS'}, {'type': 'freshsnaps', 'url': '/freshsnaps/ID/?id=289054', 'image': 'https://static.droptokyo.com/wp-content/uploads/2021/04/01110342/f2.jpg', 'name': 'KANJI &#8211; KANSAI'}, {'type': 'freshsnaps', 'url': '/freshsnaps/ID/?id=289042', 'image': 'https://static.droptokyo.com/wp-content/uploads/2021/04/01105744/d2.jpg', 'name': 'KEIJIRO ASAKA &#8211; KANSAI'}, {'type': 'freshsnaps', 'url': '/freshsnaps/ID/?id=288765', 'image': 'https://static.droptokyo.com/wp-content/uploads/2021/03/30015218/q221.jpg', 'name': 'UNKNOWN &#8211; NEW YORK'}], 'total_pages': 780}
# for x in a.get('freshsnaps'):
    # print(x.get('url'))


b = {
    'freshsnaps': {
        'name': 'ITO &#8211; TOKYO', 'job': 'MODEL', 'is_forever_heros': False, 'date': '07.04.2021', 'facebook': '', 'twitter': '', 'instagram': 'https://www.instagram.com/ito_wolf/', 'tumblr': '', 'tag': '<a href="/search/?search=HANDMADE">#HANDMADE</a> <a href="/search/?search=TOKYO">#TOKYO</a> <a href="/search/?search=USED">#USED</a>', 'content': 'Name: Ito | 弦<br />\r\nOccupation: Model | モデル<br />\r\nJacket: Handmade | ハンドメイド <br />\r\nPants: Handmade | ハンドメイド <br />\r\nShoes: Used | 古着', 'image': [{'image': 'https://static.droptokyo.com/wp-content/uploads/2021/04/07052831/y14.jpg', 'thumbnail': 'https://static.droptokyo.com/wp-content/uploads/2021/04/07052834/y23.jpg'}, {'image': 'https://static.droptokyo.com/wp-content/uploads/2021/04/07052838/y33.jpg', 'thumbnail': 'https://static.droptokyo.com/wp-content/uploads/2021/04/07052840/y43.jpg'}, {'image': 'https://static.droptokyo.com/wp-content/uploads/2021/04/07052843/y53.jpg', 'thumbnail': 'https://static.droptokyo.com/wp-content/uploads/2021/04/07052844/y61.jpg'}, {'image': 'https://static.droptokyo.com/wp-content/uploads/2021/04/07052846/y71.jpg', 'thumbnail': 'https://static.droptokyo.com/wp-content/uploads/2021/04/07052848/y81.jpg'}, {'image': 'https://static.droptokyo.com/wp-content/uploads/2021/04/07052850/y91.jpg', 'thumbnail': 'https://static.droptokyo.com/wp-content/uploads/2021/04/07052851/y101.jpg'}], 'credit': 'Photography: Yuri Horie'},
        'next': {'url': '/freshsnaps/ID/?id=289674', 'name': 'MARIKA - TOKYO'}, 'prev': {'url': '/freshsnaps/ID/?id=289684', 'name': 'TAKATO YANO - TOKYO'}}
num = 0
# for x,y in b.get('freshsnaps').items():
#     if x == 'image':
#         for i in y:
#             print(i.get('image'))



abb = '/freshsnaps/ID/?id=288813'
com = re.compile('(\d+)')
ss = re.search(com,abb).group()
print(ss)
print(type(ss))







